package demo.springcloud.test.controller;

import com.alibaba.fastjson.JSON;
import demo.springcloud.test.dto.People;
import demo.springcloud.test.dto.Student;
import demo.springcloud.test.service.StudentMapper;
import demo.springcloud.test.tool.EJBGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class HomeController {
    @Autowired
    private StudentMapper studentMapper;
    @GetMapping("/")
    public ResponseEntity<String> index(){
//        People my = People.builder().age(23).name("wang").build();
//        Student stu = generator.convert(my,Student.class);
//        String json = JSON.toJSONString(stu);
        People my = People.builder().age(26).name("zeng").build();
        Student student = studentMapper.getPeopleToStudent(my);
        log.error(JSON.toJSONString(student));
        return new ResponseEntity<>(JSON.toJSONString(student), HttpStatus.OK);
    }
}
